package com.springboot.controller;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.math.BigDecimal;

import java.text.SimpleDateFormat;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Map;

import com.alibaba.fastjson.JSON;

import org.springframework.web.bind.annotation.*;

import java.util.Calendar;

import java.util.Collections;

import java.util.Date;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import com.springboot.service.FurniturepinglunServiceImp;

import com.springboot.entity.Furniturepinglun;

import com.springboot.entity.FurniturepinglunExample;

import com.springboot.entity.*;
import com.springboot.dao.*;
import com.springboot.entity.Furniture;

import com.springboot.entity.FurnitureExample;

import com.springboot.dao.FurnitureMapper;

import com.springboot.entity.User;

import com.springboot.entity.UserExample;

import com.springboot.dao.UserMapper;

import com.springboot.entity.User;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.multipart.MultipartFile;

@Controller

@RequestMapping(value = "/")

public class FurniturepinglunController {


    private static final Log logger = LogFactory.getLog(FurniturepinglunController.class);

    @Autowired
    private FurniturepinglunServiceImp furniturepinglunservice;


    //定义方法addfurniturepinglun,响应页面addfurniturepinglun请求

    @RequestMapping(value = "addfurniturepinglun")

    public String addfurniturepinglun(HttpServletRequest request, HttpServletResponse response, HttpSession session) {

        //输出日志，当前执行方法为addfurniturepinglun

        logger.debug("FurniturepinglunController.addfurniturepinglun ......");

        furniturepinglunservice.addfurniturepinglun(request, session);

        return "addfurniturepinglun";

    }


    //定义useraddfurniturepinglun方法

    @RequestMapping(value = "useraddfurniturepinglun")

    public String useraddfurniturepinglun(HttpServletRequest request, HttpServletResponse response, HttpSession session) {

        //输出日志，表示当前正在执行FurniturepinglunController.useraddfurniturepinglun方法

        logger.debug("FurniturepinglunController.useraddfurniturepinglun ......");

        furniturepinglunservice.useraddfurniturepinglun(request, session);


        //返回添加家具评论页面

        return "useraddfurniturepinglun";

    }


    // 定义userupdatefurniturepinglun方法

    @RequestMapping(value = "userupdatefurniturepinglun")

    public String userupdatefurniturepinglun(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志FurniturepinglunController.userupdatefurniturepinglun

        logger.debug("FurniturepinglunController.userupdatefurniturepinglun ......");

        furniturepinglunservice.userupdatefurniturepinglun(request, session, id);


        // 返回user修改家具评论页面

        return "userupdatefurniturepinglun";

    }


    // 定义userfurniturepinglunmanage方法

    @RequestMapping(value = "userfurniturepinglunmanage")

    public String userfurniturepinglunmanage(HttpServletRequest request, HttpSession session, HttpServletResponse response) {

        // 输出日志，表示当前正在执行方法FurniturepinglunController.userfurniturepinglunmanage

        logger.debug("FurniturepinglunController.userfurniturepinglunmanage ......");

        furniturepinglunservice.userfurniturepinglunmanage(request, session); // 返回user家具评论管理页面

        return "userfurniturepinglunmanage";

    }


    //定义useraddfurniturepinglunact，响应页面添加家具评论请求

    @RequestMapping(value = "useraddfurniturepinglunact")

    public String useraddfurniturepinglunact(HttpServletRequest request, HttpSession session, HttpServletResponse response, Furniturepinglun furniturepinglun) throws IOException {

        //输出日志，表示当前正在执行方法为FurniturepinglunController.useraddfurniturepinglunact

        logger.debug("FurniturepinglunController.useraddfurniturepinglunact ......");

        furniturepinglunservice.useraddfurniturepinglunact(request, session, furniturepinglun); //返回到user添加家具评论方法

        return "forward:/userfurniturepinglunmanage.action";

    }


    //定义addfurniturepinglunact方法,将家具评论信息插入到数据库的t_furniturepinglun表中

    @RequestMapping(value = "addfurniturepinglunact")

    public String addfurniturepinglunact(HttpServletRequest request, HttpSession session, HttpServletResponse response, Furniturepinglun furniturepinglun, String backurl) throws IOException {

        //输出当前方法日志，表示正在执行FurniturepinglunController.addfurniturepinglunact方法

        logger.debug("FurniturepinglunController.addfurniturepinglunact ......");

        furniturepinglunservice.addfurniturepinglunact(request, session, furniturepinglun);        //如果存在返回地址，且返回地址不等于添加家具评论
        if (backurl != null && backurl.indexOf("addfurniturepinglunact.action") == -1) {
// 返回backurl所对应的方法

            return "forward:/" + backurl;
        }
        //返回家具评论管理方法，执行家具评论信息的查询

        return "forward:/furniturepinglunmanage.action";

    }


    @ResponseBody
    //定义addfurniturepinglunactjson方法

    @RequestMapping(value = "addfurniturepinglunactjson")

    public String addfurniturepinglunactjson(HttpServletRequest request, HttpSession session, HttpServletResponse response, @RequestBody Furniturepinglun furniturepinglun) throws IOException {

        //输出当前方法日志，表示正在执行FurniturepinglunController.addfurniturepinglunactjson方法

        logger.debug("FurniturepinglunController.addfurniturepinglunactjson ......");


        //调用服务层addfurniturepinglunact方法

        furniturepinglunservice.addfurniturepinglunactjson(furniturepinglun);

        //返回addfurniturepinglun方法

        return "success";

    }


    //定义furniturepinglunmanage方法响应页面请求

    @RequestMapping(value = "furniturepinglunmanage")

    public String furniturepinglunmanage(HttpServletRequest request, HttpSession session, HttpServletResponse response) {

        //输出日志，表示当前正在执行FurniturepinglunController.furniturepinglunmanage

        logger.debug("FurniturepinglunController.furniturepinglunmanage ......");


        furniturepinglunservice.furniturepinglunmanage(request, session); //返回到家具评论管理页面

        return "furniturepinglunmanage";

    }


    // 定义 furniturepinglunview方法

    @RequestMapping(value = "furniturepinglunview")

    public String furniturepinglunview(HttpServletRequest request, HttpSession session, HttpServletResponse response) {

        // 输出日志，表示当前正在执行FurniturepinglunController.furniturepinglunview方法

        logger.debug("FurniturepinglunController.furniturepinglunview ......");


        furniturepinglunservice.furniturepinglunview(request, session);

        // 返回家具评论查看页面

        return "furniturepinglunview";

    }


    // 定义 updatefurniturepinglun方法

    @RequestMapping(value = "updatefurniturepinglun")

    public String updatefurniturepinglun(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志FurniturepinglunController.updatefurniturepinglun，表示正在执行该方法

        logger.debug("FurniturepinglunController.updatefurniturepinglun ......");


        furniturepinglunservice.updatefurniturepinglun(request, session, id); // 返回修改家具评论页面

        return "updatefurniturepinglun";

    }


    // 定义updatefurniturepinglunact处理家具评论修改

    @RequestMapping(value = "updatefurniturepinglunact")

    public String updatefurniturepinglunact(HttpServletRequest request, HttpServletResponse response, Furniturepinglun furniturepinglun, HttpSession session) throws IOException {

        // 输出日志，表示正在执行当前方法FurniturepinglunController.updatefurniturepinglunact

        logger.debug("FurniturepinglunController.updatefurniturepinglunact ......");

        furniturepinglunservice.updatefurniturepinglunact(request, furniturepinglun, session);

        // 返回家具评论管理方法

        return "forward:/furniturepinglunmanage.action";

    }

    @ResponseBody
    // 定义updatefurniturepinglunactjson处理家具评论修改

    @RequestMapping(value = "updatefurniturepinglunactjson")

    public String updatefurniturepinglunactjson(HttpServletRequest request, HttpServletResponse response, @RequestBody Furniturepinglun furniturepinglun, HttpSession session) throws IOException {

        // 输出日志，表示正在执行当前方法FurniturepinglunController.updatefurniturepinglunactjson

        logger.debug("FurniturepinglunController.updatefurniturepinglunactjson ......");

        furniturepinglunservice.updatefurniturepinglunactjson(furniturepinglun);

        return "success";

    }


    // 定义userupdatefurniturepinglunact方法

    @RequestMapping(value = "userupdatefurniturepinglunact")

    public String userupdatefurniturepinglunact(HttpServletRequest request, HttpServletResponse response, Furniturepinglun furniturepinglun, HttpSession session) throws IOException {

        // 当执行此方法时，输出此日志

        logger.debug("FurniturepinglunController.userupdatefurniturepinglunact ......");

        furniturepinglunservice.userupdatefurniturepinglunact(request, furniturepinglun, session);

        // 返回user家具评论管理方法

        return "forward:/userfurniturepinglunmanage.action";

    }


    // 定义deletefurniturepinglun,处理删除家具评论

    @RequestMapping(value = "deletefurniturepinglun")

    public String deletefurniturepinglun(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志，表示当前正在执行FurniturepinglunController.deletefurniturepinglun方法

        logger.debug("FurniturepinglunController.deletefurniturepinglun ......");

        furniturepinglunservice.deletefurniturepinglun(request, session, id);

        // 返回家具评论管理方法

        return "forward:/furniturepinglunmanage.action";

    }


    @ResponseBody
    // 定义deletefurniturepinglunjson,处理删除家具评论

    @RequestMapping(value = "deletefurniturepinglunjson")

    public String deletefurniturepinglunjson(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志，表示当前正在执行FurniturepinglunController.deletefurniturepinglun方法

        logger.debug("FurniturepinglunController.deletefurniturepinglun ......");

        furniturepinglunservice.deletefurniturepinglun(request, session, id);

        return "success";

    }


    // 定义userdeletefurniturepinglun方法

    @RequestMapping(value = "userdeletefurniturepinglun")

    public String userdeletefurniturepinglun(HttpServletRequest request, HttpServletResponse response, HttpSession session, int id) {

        // 输出日志，表示当前正在执行FurniturepinglunController.userdeletefurniturepinglun方法

        logger.debug("FurniturepinglunController.userdeletefurniturepinglun ......");


        furniturepinglunservice.userdeletefurniturepinglun(request, session, id); // 返回user家具评论管理方法

        return "forward:/userfurniturepinglunmanage.action";

    }


    // 定义searchfurniturepinglun方法，处理搜索操作

    @RequestMapping(value = "searchfurniturepinglun")

    public String searchfurniturepinglun(HttpServletRequest request, HttpServletResponse response, HttpSession session, String search) {

        // 输出日志，表示当前正在执行FurniturepinglunController.searchfurniturepinglun

        logger.debug("FurniturepinglunController.searchfurniturepinglun ......");


        furniturepinglunservice.searchfurniturepinglun(request, session, search); // 返回查询家具评论页面

        return "searchfurniturepinglun";

    }


    @ResponseBody
    // 定义searchfurniturepinglunjson方法，处理搜索操作
    @RequestMapping(value = "searchfurniturepinglunjson")

    public Map searchfurniturepinglunjson(HttpServletRequest request, HttpServletResponse response, HttpSession session, String search) {

        // 输出日志，表示当前正在执行FurniturepinglunController.searchfurniturepinglunjson

        logger.debug("FurniturepinglunController.searchfurniturepinglunjson ......");


        // 定义返回结果

        Map result = new HashMap();

        // 获取返回结果

        result = furniturepinglunservice.searchfurniturepinglunjson(search); // 将结果以json返回

        return result;

    }


    // 定义FurniturepinglunpinglunMapper

    @RequestMapping(value = "furniturepinglundetails")

    public String furniturepinglundetails(HttpServletRequest request, HttpSession session, HttpServletResponse response, int id) {

        // 输入日志信息，表名当前执行方法为FurniturepinglunController.furniturepinglundetails

        logger.debug("FurniturepinglunController.furniturepinglundetails ......");


        furniturepinglunservice.furniturepinglundetails(request, session, id); // 返回家具评论详情页面

        return "furniturepinglundetails";

    }


    @ResponseBody
    // 定义Furniturepinglun详情方法

    @RequestMapping(value = "furniturepinglundetailsjson")

    public Map furniturepinglundetailsjson(HttpServletRequest request, HttpSession session, HttpServletResponse response, int id) {

        // 输入日志信息，表名当前执行方法为FurniturepinglunController.furniturepinglundetailsjson

        logger.debug("FurniturepinglunController.furniturepinglundetailsjson ......");


        Map result = new HashMap();

        result = furniturepinglunservice.furniturepinglundetailsjson(id);

        // 将结果以json返回

        return result;

    }


}

